package pers.cz.analysis.store.txt;

import pers.cz.analysis.entitys.ClassDesc;
import pers.cz.analysis.enums.ExportConf;
import pers.cz.analysis.store.IStore;
import pers.cz.analysis.utils.FileUtils;
import pers.cz.jefconfig.config.JefConfiguration;

import java.util.List;

/**
 * @program: Jef-code-analysis
 * @description: 普通文本文件
 * @author: Cheng Zhi
 * @create: 2023-10-11 21:00
 **/
public class TxtStore implements IStore {

    @Override
    public void save(List<ClassDesc> classDescList) {

        StringBuilder content = new StringBuilder();
        int i=0;
        for (ClassDesc classDesc : classDescList) {
            content.append(classDesc.getFullClassName());
            content.append("#");
            content.append(classDesc.getMethodName());
            content.append(" --");
            content.append(classDesc.getKeyWord());
            content.append("\n");
            i ++;
            if (i==100) {
                FileUtils.writeFileWithStreamByRandomAccess(JefConfiguration.get(ExportConf.JEF_ANALYSIS_SAVE_PATH), content.toString());
                content = new StringBuilder();
                i=0;
            }
        }

        FileUtils.writeFileWithStreamByRandomAccess(JefConfiguration.get(ExportConf.JEF_ANALYSIS_SAVE_PATH), content.toString());




    }
}
